home *** CD-ROM | disk | FTP | other *** search
-
- #include "FileLogger.h"
- #include "IApplication.h"
-
- namespace peon
- {
-
- IApplication::IApplication()
- {
- m_pCurrentState = NULL;
- }
-
- IApplication::~IApplication()
- {
- }
-
- bool IApplication::loadState(int key, IApplicationState* pState)
- {
-
- if(!pState->onLoad())
- {
- return false;
- }
-
- m_oStates.insert(std::make_pair(key, pState));
-
- return true;
- }
-
- void IApplication::setCurrentState( int key )
- {
-
- std::map<int, IApplicationState*>::iterator it;
- it = m_oStates.find(key);
- if (it == m_oStates.end())
- {
- FileLogger::getSingleton().logError("IApplication", "Couldn't find state");
- return;
- }
- else
- {
- m_pCurrentState = it->second;
-
- }
- }
-
- void IApplication::unloadStates()
- {
- IApplicationState* pState;
- for(std::map<int, IApplicationState*>::iterator it = m_oStates.begin();
- it != m_oStates.end();
- it++)
- {
- pState = (IApplicationState*)it->second;
- pState->onUnload();
- PEON_DELETE( pState );
-
- }
-
- //clear the map
- m_oStates.clear();
-
- }
- }